package com.lbssoft.gpsbd.datalink;


import com.lbssoft.datalink.EntityManager;
import com.lbssoft.gpsbd.common.PropertiesUtil;
import com.lbssoft.gpsbd.model.Device;
import com.lbssoft.gpsbd.model.Geofence;
import com.lbssoft.gpsbd.model.Position;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class Context {

	public static DataManager dataManager;

	public static DataManager getDataManager() {
		return dataManager;
	}

	public static void setDataManager(DataManager dataManager) {
		Context.dataManager = dataManager;
	}

	//采集中心实体管理器
	public static EntityManager entityManager;

	//设备id对应最后位置
	public static Map<Long, Position> positions = new ConcurrentHashMap<>();

	//UUID对应设备信息
	public static Map<String, Device> deviceByUuid = new ConcurrentHashMap<>();

	//UUID对应围栏信息
	public static Map<String, Geofence> geofenceByUuid = new ConcurrentHashMap<>();

	//设备id对应的用户id
	public static Map<Long, Long> userByDevice = new ConcurrentHashMap<>();


	public static void init() {
		dataManager = new DataManager();
		PropertiesUtil pro = new PropertiesUtil("application.properties");
		entityManager = new EntityManager(pro.get("gpsbd.appsecret").toString());
	}
}
